package me.spring.cloud.common.components.page;

import com.github.pagehelper.PageInfo;
import me.spring.cloud.common.components.rpc.page.Page;
import me.spring.cloud.common.components.rpc.page.PageResultList;

import java.util.List;

/**
 * @description: 分页数据组装工具类
 * @author: luffy
 * @create: 2018-08-28 09:52
 **/
public class PageUtil {
    /** 
    * @Param: [page, list]
    * @Author: luffy
    * @Date: 2018/8/28 10:22
    */ 
    public static <T> PageResultList<T> newPage(Page page, List<T> list) {
        PageInfo<T> pageInfo = new PageInfo<>(list);
        return new PageResultList<>(page, pageInfo.getTotal(), pageInfo.getPages(), pageInfo.getList());
    }

}
